package band.wukong.practice.javase.core.regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by IntelliJ IDEA.
 * User: Johnson
 * Date: 2012-8-30 16:25:49
 * To change this template use File | Settings | File Templates.
 */
public class TestFinding {
    public static void main(String[] agrs) {
        testFinding();

    }

    /**
     * Desc：使用find。
     */
    private static void testFinding() {
        Matcher m = Pattern.compile("\\w+")
                .matcher("Evening is full of the linnet's wings");
        while (m.find())
            System.out.print(m.group() + " ");
        System.out.println();
        int i = 0;
        while (m.find(i)) {
//            System.out.print(m.group() + " ");
            System.out.println("[" + m.group() + "]");
            i++;
        }

        /* Output:
            Evening is full of the linnet s wings
            Evening vening ening ning ing ng g is is s full full ull ll l of of f the the he e linnet linnet innet nnet net et t s s wings wings ings ngs gs s
        *///:~
    }
}
